/**
  ETFAna project, Anyang Normal University && IMP-CAS
  \class ETFPIDm
  \brief inherited from ETFVPID - 
  \author SUN Yazhou, asia.rabbit@163.com
  \since 2023-06-02
  \date 2023-06-02 last modified
  \attention
  changelog
  <table>
  <tr>  <th>Date         <th>Author      <th>Description                   </tr>
  <tr>  <td>2023-06-02   <td>Asia Sun    <td>file created                  </tr>
  </table>

  \copyright Copyright (c) 2021-2024 Anyang Normal U. && IMP-CAS with LGPLv3 LICENSE
*/

#ifndef ETFPIDm_h
#define ETFPIDm_h

#include <vector>
#include "ETFVPID.h"

using std::vector;

class ETFPostMagTracker;
class ETFParticle;
class ETFTOFWall;
class TClonesArray;

class ETFPIDm : public ETFVPID{
public:
  ETFPIDm();
  virtual ~ETFPIDm();

  virtual void Initialize() override;
  virtual void Register() override; ///< register to the main tree

  /// \brief the general fly function that will actually be called by the program
  /// \param is3D: whether using 3D tracks
  /// \param istof: whether we only call fly to calculate tof2
  /// \retval false: not eligible for PID
  virtual bool Fly(bool istof = false) override;
  using ETFVPID::Fly;
  /// \brief only fly those tracks in \param trker
  virtual bool Fly(ETFPostMagTracker *trker, bool is3D = true, bool istof = false);
  /// propogate the particle in the dipole magnet from the target-hit point
  /// to meet the post-mag trk
  /// \param tofw: the TOFWall belonging to the current tracker
  /// help to provide total flight path length
  virtual bool Fly(const ETFTOFWall *tofw);

  TClonesArray *GetParticles(){ return fpidv; }
  TClonesArray *pid(){ return fpidv; }

  /// get the hit position on the target, i.e., assigning fTaHitX
  virtual bool GetTaHitPos();
  virtual void ConstructGraph() override; ///< update fCurve

  virtual void Print() override;
  const ETFParticle *GetParticle(int i) const;
  int GetNofParticles() const; // { return fpidv->GetEntriesFast(); }

  ClassDefOverride(ETFPIDm, 1); ///< particle identification

protected:
  double fTaHitX; ///< the X hit position on the target
  ETFParticle *fParticle; //! ///< a temporary variable storing the info of one particle
  TClonesArray *fpidv; //! ///< the vector storing pid info of light fragments
};

#endif
